<template>
  <div style="width: 100%;height: 100%;">
    <Echart
      :options="options"
      :id="id"
      height="100%"
      width="100%"
    ></Echart>
  </div>
</template>

<script>
  import Echart from '@/common/echart'
  export default {
    data () {
      return {
        options: {},
      };
    },
    components: {
      Echart,
    },
    props: {
      cdata: {
        type: Object,
        default: () => ({})
      },
      id: {
        type: String
      }
    },
    watch: {
      cdata: {
        handler (newData) {
          this.options = {
            tooltip: {
              trigger: 'axis'
            },
            legend: {
              data: newData.legendList,
              top: "4%"
            },
            calculable: true,
            grid: {
              left: "12%",
              bottom: "15%",
              top: "15%",
              width: "80%"
            },
            xAxis: [
              {
                type: 'category',
                data: newData.xAxisList
              }
            ],
            yAxis: [
              {
                type: 'value'
              }
            ],
            series: newData.seriesList
          }
        },
        immediate: true,
        deep: true
      }
    }
  };
</script>

<style lang="scss" scoped>
</style>
